import concurrent.futures
import threading


# 执行器注册监控， 多线程轮询的方式，查询执行器是否已经被注册过，防止重复注册

class jobRegistryHelper:

    def __init__(self):
        self.logger = None
        self.instance = None
        self.registryOrRemove = None
        self.registryMonitorThread = None
        self.toStop = None


    def start(self):

        # 用于注册或删除
        self.registryOrRemoveThreadPool = concurrent.futures.ThreadPoolExecutor(10).submit()

        # 用于监控
        self.registryMonitorThread = threading.Thread(
            self._monitor()
        ).start()

    def _monitor(self):
        while self.toStop:
            set(self.address)

    # 执行器注册
    def registry(self, registryParam):
        self.registryOrRemoveThreadPool.submit()